package com.chenyu.pojo;

/**
 * 人class  重写hashcode  和 equals 方法
 */
public class Person {

	private String name;
	private String pwd;
	private int age;
	
	public Person(){
		
	}
	public Person(String name, String pwd, int age) {
		super();
		this.name = name;
		this.pwd = pwd;
		this.age = age;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getPwd() {
		return pwd;
	}

	public void setPwd(String pwd) {
		this.pwd = pwd;
	}

	public int getAge() {
		return age;
	}

	public void setAge(int age) {
		this.age = age;
	}

	@Override
	public boolean equals(Object o) {
		if (o == this) return true;
		if (!(o instanceof Person))
			return false;
		Person user = (Person) o;
		return user.name.equals(name) && user.age == age;
	}

	@Override
	public int hashCode() {
		int result = 17;
		result = result * 31 + name.hashCode();
		result = result * 31 + age;
		return result;
	}
}
